<template>
  <div class="app-container">
    <el-row>
        <el-col :span="18">
    <el-form ref="form" :inline="true" :model="form" label-width="80px">
      <el-form-item label="输入搜索">
        <el-input v-model="form.sousuo"></el-input>
      </el-form-item>
      <el-form-item label="收件人">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="提交时间">
        <el-input v-model="form.date"></el-input>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-select v-model="form.region" placeholder="请选择活动区域">
          <el-option label="已完成" value=""></el-option>
          <el-option label="已发货" value=""></el-option>
          <el-option label="未发货" value=""></el-option>
        </el-select> </el-form-item>
        <el-form-item label="订单分类">
        <el-select v-model="form.fellei" placeholder="请选择活动区域">
          <el-option label="已关闭" value=""></el-option>
          <el-option label="待发货" value=""></el-option>
          <el-option label="已发货" value=""></el-option>
          <el-option label="已完成" value=""></el-option>
        </el-select> </el-form-item>
        <el-form-item label="订单来源">
        <el-select v-model="form.laiyuan" placeholder="请选择活动区域">
          <el-option label="APP订单" value=""></el-option>
          <el-option label="其他" value=""></el-option>
        </el-select> </el-form-item>
</el-form></el-col>
<el-col :span="4">
    <el-button>重置</el-button>
    <el-button type="primary">查询搜索</el-button>
</el-col>
</el-row>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="Title">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="Author" width="110" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.author }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Pageviews" width="110" align="center">
        <template slot-scope="scope">
          {{ scope.row.pageviews }}
        </template>
      </el-table-column>
      <el-table-column
        class-name="status-col"
        label="Status"
        width="110"
        align="center"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{
            scope.row.status
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="created_at"
        label="Display_time"
        width="200"
      >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="created_at"
        label="操作"
        width="200"
      >
        <template slot-scope="scope">
            <el-button to="/dingdan/dingdanset">查看订单</el-button>
            <el-button @click="deldingdan(scope.$index)" type="danger">删除订单</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
  
  <script>
import { getList } from "@/api/table";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger",
      };
      return statusMap[status];
    },
  },
  data() {
    return {
        form: {
            sousuo:'',
            date:'',
          name: '',
          region: '',
          fenlei:'',
          laiyuan:'',
        },
      list: null,
      listLoading: true,
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    deldingdan(e) {
        this.$confirm('确认删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            this.list.splice(e, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
    fetchData() {
      this.listLoading = true;
      getList().then((response) => {
        this.list = response.data.items;
        this.listLoading = false;
      });
    },
  },
};
</script>
  